<%@ taglib prefix="c" uri="/struts-tags" %>
<%@ page import="com.zzc.bean.Employee" %>
<%@ page import="java.util.List" %>
<%@ page import="com.zzc.bean.Techer" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.net.URLDecoder" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="com.zzc.bean.Dining" %>
<%@ page import="com.zzc.bean.DiningReceipt" %>
<%--
  Created by IntelliJ IDEA.
  Employee: HP
  Date: 2017/11/7
  Time: 15:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Title</title>
</head>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<script type="text/javascript" src="<%=path%>/assets/js/jquery-3.3.1.js"></script>
<script type="text/javascript" src="<%=path%>/assets/bootstrap/js/moment.js"></script>
<script type="text/javascript" src="<%=path%>/assets/js/main.js"></script>
<script type="text/javascript" src="<%=path%>/assets/bootstrap/js/transition.js"></script>
<script type="text/javascript" src="<%=path%>/assets/bootstrap/js/collapse.js"></script>
<script type="text/javascript" src="<%=path%>/assets/bootstrap/js/bootstrap.js"></script>
<script type="text/javascript" src="<%=path%>/assets/bootstrap/js/bootstrap-datetimepicker.js"></script>
<link href="<%=path%>/assets/bootstrap/css/bootstrap-datetimepicker.css" rel="stylesheet" />
<link href="<%=path%>/assets/bootstrap/css/bootstrap.css" rel="stylesheet" />
<link href="<%=path%>/assets/bootstrap/css/bootstrap-datetimepicker-standalone.css" rel="stylesheet" />
<body>
<%
    List<DiningReceipt> list_diningReceipts = (List<DiningReceipt>) request.getAttribute("list_diningReceipts");
    String result_info_add=request.getParameter("result_info_add");
%>
<%
    if (result_info_add!=null){
        result_info_add=new String(request.getParameter("result_info_add").getBytes("iso8859-1"),"UTF-8");
%>
<script type="text/javascript">
    alert('<%=result_info_add%>');
</script>
<%
    }
%>
<div align="center">
    <div align="right">
        <%
            Employee employee= (Employee) session.getAttribute("employee");
            request.setAttribute("employee_account",employee.getEmployee_account());
        %>
<%--        用户:<%=employee.getEmployee_name()%>--%>
    </div>
    <div align="center">
        <h2>Introducir las informaciones de reserva</h2>
        <form action="<%=path%>/Action/Action_DiningReceiptAction_add" method="post">
            Num. de usuario:<input type="text" name="dining_account" value="<%=employee.getEmployee_account()%>" readonly="readonly"/><br/>
            Nom. de empresa:<input type="text" name="dining_company" value="<%=employee.getEmployee_company()%>" readonly="readonly" /><br/>
            Fecha:
            <input id="dining_time" name="dining_time" type="date" value="2018-01-01"/><br/>
            Tipo:
            <select id="dining_type" data-options="editable:false">
                <option value="Almuerzo" selected="selected">Almuerzo</option>
                <option value="Cena">Cena</option>
            </select>
            <br/>
            Num. de dirigentes:<input type="text" name="leadership_number" value="0" onkeyup="checkInput(this)"/><br/>
            Num. de empleados:<input type="text" name="employee_number" value="0" onkeyup="checkInput(this)"/><br/>
            Notas:<input type="text" name="note"/><br/>
<%--            <button class="submit_button">提交</button>--%>
<%--            <input type="submit" value="提交" />--%>
        </form>
        <button id="submit_button"  name="submit_button" class="submit_button" onclick="submitButtonClick()">Entrega</button>
    </div>
</div>
</body>
<script type="text/javascript">
    function getTime() {
        $("#dining_time").attr("value",getFormatDate_dining());
    }
    getTime();
    function submitButtonClick(){
        $("#submit_button").attr("disabled","true");
        var dining_account=$("input[name='dining_account']").val();
        var dining_company=$("input[name='dining_company']").val();
        var dining_time=$("input[name='dining_time']").val();
        var dining_type=$('#dining_type').val();
        var leadership_number=$("input[name='leadership_number']").val();
        var employee_number=$("input[name='employee_number']").val();
        var note=$("input[name='note']").val();
        var data = { dining_account: dining_account,dining_company: dining_company,dining_time: dining_time,dining_type: dining_type,leadership_number: leadership_number,employee_number: employee_number,note: note};
        $.post('<%=path%>/Action/Action_DiningReceiptAction_add', data, function (ret) {
            console.log(ret);
            console.log(ret.code);
            console.log(ret.data);
            if (ret&& ret.code === 200) {
                console.log(ret.data);
                if (ret.data) {
                    if (ret.data=='true'){
                        location.href ="<%=path%>/Action/Action_DiningReceiptAction_get_employee_account";
                    }
                    else{
                        alert(ret.data);
                    }
                }
            }
            else{
                alert("Parece que la confirmación falló, tal vez un problema de red");
                location.reload();
            }
        }).fail(function () {
            alert('Confirmación fallida: ¿error de red?');
            $("#submit_button").attr("disabled",false);
        });
    }
</script>
</html>
